#include "../headers/Main.h"

 #define CURL_ICONV_CODESET_OF_HOST "UTF-8"
 #define CURL_ICONV_CODESET_OF_NETWORK "UTF-8"
 #define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8" 

// Writen by NeXoSE:
// @scURL = URL of WebInterface
// @scURL = Data(String)
HK_ERROR cURL(const char *scURL, const char *scData)
{
	string sURL = "";
	sURL += scURL;
	sURL += "/WebFront_Interface.php";

	CURL *  curl;
	curl = curl_easy_init();

    if(curl) {
        CURLcode res; 
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
		curl_easy_setopt(curl, CURLOPT_TIMEOUT, 8);
		res = curl_easy_setopt(curl, CURLOPT_URL, sURL);
		res = curl_easy_setopt(curl, CURLOPT_USERAGENT, "Freelancer Web Front-End Client For FLHook");

		curl_easy_setopt(curl, CURLOPT_POST, true);
		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, scData);
		curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(scData)); 

        res = curl_easy_perform(curl);
        if(CURLE_OK == res) {
            char *ct;
            res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, & ct);
        }
        curl_easy_cleanup(curl);
		if (bSet_Showoutput) {
			ConPrint(L"[FLBorad] -> ");
			ConPrint(s2ws(scURL));
			ConPrint(L" -> ");
			ConPrint(s2ws(scData));
			ConPrint(L"\n");
		}
		return HKE_OK;
    }
    return HKE_UNKNOWN_ERROR;
}